/*
// * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.commands;

import edu.wpi.first.wpilibj.templates.RobotMap;


/**
 *
 * @author Developer
 */
public class teleShoot extends CommandBase {
    public teleShoot() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(load);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        
        if(RobotMap.upperLimit.get())
        {
            System.out.println("UpperLimit");
            if (RobotMap.elevatorMotor.get() > 0)
            {
                System.out.println("teleShoot");
                RobotMap.elevatorMotor.set(0);
            }
        }
        else 
        {
            RobotMap.loadMotor.set(-1);
            RobotMap.shooter1.set(1);
            RobotMap.loaderServo.setAngle(170);
            //if hits the speed limit
            // set it .3
            //else
            //set to 1
            if (RobotMap.slowLimit.get())
            {
                System.out.println("SlowLimit");
                oi.elevator_speed = 0.3;
            }
            RobotMap.elevatorMotor.set(oi.elevator_speed);
        }
        if (RobotMap.upperLimit.get())
        {
            oi.elevator_state = 1; 
        }
     
        //Safety
        if(RobotMap.lowerLimit.get())
        {
            if (RobotMap.elevatorMotor.get() < 0)
            {
                oi.elevator_state = 0;
                RobotMap.elevatorMotor.set(0);
            }
        }
        if(RobotMap.upperLimit.get())
        {
            if (RobotMap.elevatorMotor.get() > 0)
            {
                oi.elevator_state = 1;
                RobotMap.elevatorMotor.set(0);
            }
        }
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        if(RobotMap.upperLimit.get())
        {
            oi.elevator_state = 1;
            RobotMap.elevatorMotor.set(0);
            RobotMap.loadMotor.set(0);
            RobotMap.shooter1.set(0);
            return true;
        }
        return false;
    }
    // Called once after isFinished returns true
    protected void end()
    {    
    }
    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
        /*
        RobotMap.loadMotor.set(0);
        RobotMap.shooter1.set(0);
        RobotMap.elevatorMotor.set(0);
        */
    }
}
